package com.kornero.auto.util.email;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class EmailProvider {

    private static final Logger logger = LoggerFactory.getLogger(EmailProvider.class);

    private static final BlockingQueue<Email> EMAILS = loadEmails();

    public static Email getNextEmail() {
        final Email email = EMAILS.poll();
        EMAILS.add(email);
        return email;
    }

    private static BlockingQueue<Email> loadEmails() {
        final BlockingQueue<Email> emails = new LinkedBlockingQueue<>();
        emails.add(new Email("UpdateChecker@mail.ru", "q1w2e3R4"));
        emails.add(new Email("UpdateChecker2@mail.ru", "q1w2e3R4"));
        emails.add(new Email("UpdateChecker3@mail.ru", "q1w2e3R4"));
        emails.add(new Email("UpdateChecker4@mail.ru", "q1w2e3R4"));
        emails.add(new Email("UpdateChecker5@mail.ru", "q1w2e3R4"));
        return emails;
    }
}
